package com.example.myapplication1;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class BaseAdapterActivity extends AppCompatActivity {

    public List<Msg> data= new ArrayList<>();
    public ListView mListView;
    public ImageView fabu;
    public MyAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list_view2);

        mListView=findViewById(R.id.listview3);
        fabu=findViewById(R.id.fabu);

        initData();

        MyAdapter adapter= new MyAdapter(data,this,R.layout.item4);

        mListView.setAdapter(adapter);
        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Toast.makeText(BaseAdapterActivity.this,"第"+(i+1)+"行被点击了",Toast.LENGTH_SHORT);
            }
        });

    }

    private void initData() {

        Msg msg1=new Msg(R.mipmap.profile1,"小🐖","放假啦~~",true);
        Msg msg2=new Msg(R.mipmap.profile2,"小羊","放假啦~~",false);
        Msg msg3=new Msg(R.mipmap.profile3,"小狗","放假啦~~",false);
        Msg msg4=new Msg(R.mipmap.profile4,"小猫","放假啦~~",true);
        Msg msg5=new Msg(R.mipmap.profile5,"小兔","放假啦~~",false);
        Msg msg6=new Msg(R.mipmap. profile6,"动物园管理员","nice,不用管这群崽子了",true);
        Msg msg7=new Msg(R.mipmap.profile7,"哈哈哈哈哈哈","红红火火恍恍惚惚",false);
        Msg msg8=new Msg(R.mipmap.profile8,"芜湖","起飞🛫",false);

        data.add(msg1);
        data.add(msg2);
        data.add(msg3);
        data.add(msg4);
        data.add(msg5);
        data.add(msg6);
        data.add(msg7);
        data.add(msg8);

    }


}